package cn.livingCloud.controller.core.validator;

import cn.livingCloud.dto.CaseCategoryChangeFormDto;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

/**
 * Created by 唐旭 on 2016/6/5.
 */
@Component
public class CaseCategoryChangeFormDtoValidator implements Validator {
    @Override
    public boolean supports(Class<?> aClass) {
        return CaseCategoryChangeFormDto.class.equals(aClass);
    }

    @Override
    public void validate(Object o, Errors errors) {
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "uuid", null, "");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "categoryUuid", null, "请选择一个分类");
    }
}
